package com.guet.common.response;


import lombok.Data;

import java.io.Serializable;

/**
 * @author dragon
 */
@Data
public class ResultVO<T> implements Serializable {
    private static final long serialVersionUID = -1165593239492918497L;
    // 业务码
    private Integer code;
    // 处理结果的简要描述
    private String msg;
    // 处理结果
    private T data;

    public ResultVO() {
    }

    // 用在无返回数据的接口上
    public ResultVO(ResultCodeEnum resultCode) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }

    // 用在有返回数据或者有详细错误描述的接口上
    public ResultVO(ResultCodeEnum resultCode, T data) {
        this(resultCode);
        this.data = data;
    }

    // 自定义业务码以及返回数据
    public ResultVO(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
